<?
class AdvertisingController extends BaseController{
    var $table = 'advertising';
    var $id_field = 'adv_id';
    var $name_field = 'adv_source';
    var $thumb_field = 'adv_picture';
    var $record_id;
    public function __construct($id = null){
        parent::__construct();
    }
    
    public function GetListAdvertising($iCat = 0) {
        $db_query = new db_query('SELECT adv_id,adv_source,adv_position,adv_type,adv_link,adv_start,adv_end,adv_category,
                                         adv_active,adv_picture
                                  FROM advertising
                                  WHERE 1 AND adv_active = 1 AND adv_end > "'.time().'"
                                  ORDER BY adv_position ASC
                                  LIMIT 12');
        $list_adv = array();
        while($row = mysql_fetch_assoc($db_query->result)) {
            $adv = array();
            $arrayCat = explode(',',$row['adv_category']);
            if(in_array($iCat, $arrayCat)) {
                $adv['title'] = $row['adv_source'];
                $adv['link'] = $row['adv_link'];
                $adv['picture'] = PATH_PICTURE_ADV.$row['adv_picture'];
                $list_adv[] = $adv;
            }
        }unset($db_query);
        $html = AdvertisingLayout::list_advertising(array('adv'=>$list_adv));
        return $html;
        
    }
    
}
?>